<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('售后产品信息列表')" />
    <style>
        .changeColor{
            background-color: #23c6c8  !important;
            color: white;
        }
    </style>
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>售后厂家：</label>
                                <input type="text" name="factoryName"/>
                            </li>
                            <li>
                                <label>产品分类：</label>
                                <input type="text" name="typeName"/>
                            </li>
                            <li>
                                <label>产品品牌：</label>
                                <input type="text" name="productBrand"/>
                            </li>
                            <li>
                                <label>产品型号：</label>
                                <input type="text" name="productModel"/>
                            </li>
                            <li>
                                <label>产品规格：</label>
                                <input type="text" name="productAttribute"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <!--<div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="zsyh:afterProduct:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="zsyh:afterProduct:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="zsyh:afterProduct:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="zsyh:afterProduct:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>-->
            <div class="col-sm-12 select-table table-bordered">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('zsyh:afterProduct:edit')}]];
        var removeFlag = [[${@permission.hasPermi('zsyh:afterProduct:remove')}]];
        var prefix = ctx + "zsyh/afterProduct";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                modalName: "售后产品信息",
                columns: [{
                    field : 'Number',
                    title : '序号',
                    align: 'center',
                    width: 20,
                    formatter : function(value, row, index) {
                        var pageSize = $('#bootstrap-table').bootstrapTable('getOptions').pageSize;//通过表的#id 可以得到每页多少条
                        var pageNumber = $('#bootstrap-table').bootstrapTable('getOptions').pageNumber;//通过表的#id 可以得到当前第几页
                        return pageSize * (pageNumber - 1) + index + 1;//返回每条的序号： 每页条数 * （当前页 - 1 ）+ 序号
                    }
                },
                {
                    field: 'id',
                    title: '产品Id',
                    align: 'center',
                    visible: false
                },
                {
                    field: 'factoryName',
                    align: 'center',
                    title: '售后厂家'
                },
                    {
                        field: 'productImages',
                        align: 'center',
                        title: '产品图片',
                        formatter: function(value, row, index) {
                            var actions = [];
                            actions.push('<a  href="javascript:void(0)" onclick="openAttributeImage(\'' + row.productImages + '\')">查看</a> ');
                            return actions.join('');
                        }
                    },
                {
                    field: 'typeName',
                    align: 'center',
                    title: '产品分类'
                },
                {
                    field: 'productBrand',
                    align: 'center',
                    title: '产品品牌'
                },
                {
                    field: 'productModel',
                    align: 'center',
                    title: '产品型号'
                },
                {
                    field: 'productAttribute',
                    align: 'center',
                    title: '产品规格'
                },

                /*{
                    field: 'productRemarks',
                    align: 'center',
                    title: '产品描述'
                },
                {
                    field: 'productFault',
                    align: 'center',
                    title: '常见故障'
                },*/
                ],onDblClickRow: function (row) {
                    parent.$('#productName').val(row.factoryName+" "+row.typeName+" "+row.productBrand+" "+row.productModel+" "+row.productAttribute);
                    parent.$('#productId').val(row.id);
                    $.modal.close();
                },
                onClickRow:function (row,$element) {
                    $('.changeColor').removeClass('changeColor');//移除class
                    $($element).addClass('changeColor');//添加class
                }
            };
            $.table.init(options);
        });

        function openAttributeImage(attributeImage){
            $.modal.open("查看图片", attributeImage);
        }

        function viewProduct(id) {
           /* $.modal.open("查看售后产品信息", prefix + "/edit/"+id);*/

            layer.open({
                type: 2,
                area: ['1200px', ($(window).height() - 150) + 'px'],
                fix: false,
                //不固定
                maxmin: true,
                shade: 0.3,
                title: "查看售后产品信息",
                content: prefix + "/edit/"+id,
                btnClose: 1,
                btn: [],
                // 弹层外区域关闭
                shadeClose: true,
                yes: function(index, layero) {
                    var iframeWin = layero.find('iframe')[0];
                    iframeWin.contentWindow.submitHandler(index, layero);
                },
                cancel: function(index) {
                    return true;
                }
            });

        }

    </script>
</body>
</html>